package com.ruoyi.web.controller.conmentsComplain;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.conmentsComplain.domain.CommentsComplain;
import com.ruoyi.conmentsComplain.service.ICommentsComplainService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 回复举报 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-10-15
 */
@Controller
@RequestMapping("/conmentsComplain/commentsComplain")
public class CommentsComplainController extends BaseController
{
    private String prefix = "conmentsComplain/commentsComplain";

	private String prefix2 = "conmentsComplain/commentsComplainRecord";


	
	@Autowired
	private ICommentsComplainService commentsComplainService;
	
	@RequiresPermissions("conmentsComplain:commentsComplain:view")
	@GetMapping()
	public String commentsComplain()
	{
	    return prefix + "/postResponse";
	}



	@RequiresPermissions("conmentsComplain:commentsComplain:view")
	@GetMapping("/record")
	public String commentsComplainRecord()
	{
		return prefix2 + "/commentsComplain";
	}

//	@RequiresPermissions("conmentsComplain:commentsComplain:view")
//	@GetMapping()
//	public String commentsComplain()
//	{
//		return prefix + "/commentsComplain";
//	}
	
	/**
	 * 查询回复举报列表
	 */
	@RequiresPermissions("conmentsComplain:commentsComplain:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(CommentsComplain commentsComplain)
	{
		startPage();
        List<CommentsComplain> list = commentsComplainService.selectCommentsComplainList(commentsComplain);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出回复举报列表
	 */
	@RequiresPermissions("conmentsComplain:commentsComplain:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CommentsComplain commentsComplain)
    {
    	List<CommentsComplain> list = commentsComplainService.selectCommentsComplainList(commentsComplain);
        ExcelUtil<CommentsComplain> util = new ExcelUtil<CommentsComplain>(CommentsComplain.class);
        return util.exportExcel(list, "commentsComplain");
    }
	
	/**
	 * 新增回复举报
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存回复举报
	 */
	@RequiresPermissions("conmentsComplain:commentsComplain:add")
	@Log(title = "回复举报", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(CommentsComplain commentsComplain)
	{		
		return toAjax(commentsComplainService.insertCommentsComplain(commentsComplain));
	}

	/**
	 * 修改回复举报
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		CommentsComplain commentsComplain = commentsComplainService.selectCommentsComplainById(id);
		mmap.put("commentsComplain", commentsComplain);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存回复举报
	 */
	@RequiresPermissions("conmentsComplain:commentsComplain:edit")
	@Log(title = "回复举报", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(CommentsComplain commentsComplain)
	{		
		return toAjax(commentsComplainService.updateCommentsComplain(commentsComplain));
	}
	
	/**
	 * 删除回复举报
	 */
	@RequiresPermissions("conmentsComplain:commentsComplain:remove")
	@Log(title = "回复举报", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(commentsComplainService.deleteCommentsComplainByIds(ids));
	}
	
}
